<%@ include file="/en/jsp/static.jsp" %>
<%@ page import="java.util.*, linuxbox.filelib.logic.*,linuxbox.admin.logic.*,linuxbox.admin.bean.*" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>

<jsp:include page="/en/jsp/header.jsp" flush="true"/>

<%
  FileLibHome home = FileLibHome.getInstance();
  FileLibEntry entry = (FileLibEntry)session.getAttribute("filelib.CURENTRY");
  if (entry == null)
  {
    pageContext.forward(BoxStatic.errorJSP);
    return;
  }

  String location = home.getPathString(entry.getParent());
  UserManager um = UserManager.getInstance();
  User user = null;
  boolean bInherit = ((entry.getAttributes() & home.INHERIT) != 0);
  String inheritEntryName = null;
  String curEntryName = null;
  Collection parentPermissions = null;
  if (entry.getID() == home.ROOT)
    parentPermissions = home.getPermissionList(entry);
  else
    parentPermissions = home.getPermissionList(home.get(entry.getParent()));
  Collection curPermissions = home.getPermissionList(entry);
%>

<script Language="JavaScript">
  function confirmDel()
  {
    if (confirm("Are you sure to delete file?"))
    {
       window.location='<%=BoxStatic.servletDir%>EditFileAction?SubmitDelete=del&ID=<%=entry.getID()%>';
       return true;
    }
    return false;
  }
</script>

<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
  <tr>
    <td>
	    &nbsp;<img src="<%=BoxStatic.imageDir%>itemball.jpg" width=14 height=15 border=0 align="absmiddle">
	    <b><%=boxName%> - File Library&nbsp; - Edit File</b>
    </td>
    <td align=right>
      <a href="<%=BoxStatic.servletDir%>BoxFileLibSettingsAction?SubmitEdit=edit">
        Settings
      </a>
    </td>
  </tr>
</table>
<hr width=\"100%\" color=#E06000 align=left>

  <table width= "100%" border=1 cellspacing=0 cellpadding=1>
        <form action="<%=BoxStatic.servletDir%>UploadFileAction" method=post ENCTYPE="multipart/form-data">
    <tr><td>
      <input type=submit value=
<%
      if (entry.getID()==-1)
        out.println("\"Add\" name=SubmitSave onclick=\"onSubmit()\"");
      else
      {
        out.println("\"Update\" name=SubmitSave onclick=\"onSubmit()\">");
        out.println("<input type=button value=Delete name=SubmitAskDelete Onclick='return confirmDel()'");
      }
%>
            >
        <input type="button" value="Cancel" onclick="window.location='<%=BoxStatic.servletDir%>FolderContentAction?FOLDERID=<%=entry.getParent()%>'" >
    </td></tr>
    <TR  bgcolor="#7EC1F3" >
      <TD colSpan=2> <b><font size="+1">General:</font></b>
      </TD>
    </TR>
    <tr><td>
      <table border=0 width="100%" bgcolor=#e0e0e0 style="font-size:14px">
          <input type=hidden name=ID value=<%=entry.getID()%>>
          <tr><td>
            <b>Location:</b> <%=location%>
          </td></tr>
          <tr><td>
            Name:<b><input type=text name=NAME size=40 value="<%=((entry.getName()==null)?"":entry.getName())%>"></b>If left empty will use the filename you uploaded.
          </td></tr>
<%
  if (entry.getID() != 0)
  {
%>
          <tr><td>
            Filename:<b><input type=text name=FILENAME size=40 value="<%=((entry.getFilename()==null)?"":entry.getFilename())%>"></b> If left empty will use the filename you uploaded.
          </td></tr>
<%
  }
%>
          <TD>
            Attach File: <input name="attfile"  size=40 type="file">
          </TD>
          <tr><td>
            <b><INPUT TYPE="checkbox" name="READONLY" value="1"
              <% if ((entry.getAttributes()&home.READONLY) != 0)
                   out.print(" checked ");
              %>
              >Readonly</b>&nbsp;&nbsp;
          </td></tr>
          <tr><td>
            <b>Description:</b><br>
            <textarea name=DESCRIPTION rows=5 cols=60><%=((entry.getDescription()==null)?"":entry.getDescription())%></textarea><br>
          </td></tr>

      </table>
    </td></tr>
 <%@include file="SecurityEdit.jsp" %>

        </form>
  </table>

  <hr width=\"100%\" color=#E06000 align=left>

<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
